package ir.values;

import ir.values.users.GlobalVariable;

import java.util.LinkedList;

public class ModuleIr extends Value {
    private final LinkedList<FunctionIr> functionIrs = new LinkedList<>();
    private final LinkedList<GlobalVariable> globalVariables = new LinkedList<>();
    public ModuleIr() {
        super(null, null);
    }
    public void addFunction(FunctionIr functionIr) {
        functionIrs.add(functionIr);
    }
    public void addGlobalVariable(GlobalVariable globalVariable) {
        globalVariables.add(globalVariable);
    }
    @Override
    public String parseLLVM() {
        StringBuilder sb = new StringBuilder();
        for (GlobalVariable globalVariable: globalVariables) {
            sb.append(globalVariable.parseLLVM());
        }
        for (FunctionIr functionIr : functionIrs) {
            sb.append(functionIr.parseLLVM());
        }
        return sb.toString();
    }


}
